package P1.weiyunsuan;

import java.util.Scanner;

/**
 * @Date : 2023-03-01
 * @Description: 二进制中1的个数
 */
public class BinaryWIthOne {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        while(n--!=0){
            int x = sc.nextInt();
            int res =0;
            while(x!=0) {
                x-=lowbit(x);
                res++;
            }//每次减去x最后一位1
            System.out.print(res+" ");

        }

    }
    // x & -x == x & (~x + 1)
    public static int lowbit(int x){
        return x&-x;  //返回最后一位1
    }
}
